#include<stdio.h>
#include <windows.h>

int main() 
{ 
	char buf1[] = "xxxxxxYOu~";
	char buf2[] = "THANk";


	printf("%s\n",buf1);
	WriteProcessMemory(GetCurrentProcess(),buf1,buf2,sizeof(buf2)-1,NULL);//GetCurrentProcess() get the handle of current process
	printf("%s\n",buf1);
	return 0; 
} 


/*
char *buf1 = "xxxxxxYOu~";
char buf2[] = "Love";
DWORD dwCurPid = GetCurrentProcessId();
HANDLE hProc = NULL;
hProc = ::OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_OPERATION ,false,dwCurPid);
printf("%s\n",buf1);
DWORD lpdword=0;
VirtualProtectEx(hProc,buf1,strlen(buf1),PAGE_EXECUTE_READWRITE,&lpdword);//change privilege 
WriteProcessMemory(hProc,buf1,buf2,sizeof(buf2)-1,NULL);
printf("%s\n",buf1);
*/

/*
static HANDLE hToken;
static TOKEN_PRIVILEGES tp;
static LUID luid;
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES
   |TOKEN_QUERY,&hToken);
    LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&luid);
tp.PrivilegeCount=1;
tp.Privileges[0].Luid=luid;
tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),NULL,NULL);
*/

/*
void CYCs_MsgDlg::OnShutdown()
{

ExitWindowsEx(EWX_POWEROFF,0);
}

void CYCs_MsgDlg::OnOnreset()
{

ExitWindowsEx(EWX_REBOOT,0);
}

void CYCs_MsgDlg::OnLogout()
{

ExitWindowsEx(EWX_LOGOFF,0);
}
*/